<template>
  <div>
    <el-form :inline="true" :model="searchForm" class="demo-form-inline search-view">
      <el-form-item label="关键字">
        <el-input v-model="searchForm.keyWord" placeholder="请输入关键字"></el-input>
      </el-form-item>
      <el-form-item label="分类">
        <el-select v-model="searchForm.type" placeholder="请选择">
          <el-option v-for="item in typeList" :key="item" :label="item" :value="item">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="handleSearch" class="search-button">查询</el-button>
        <el-button type="primary" @click="add" class="new-button">保存</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="tableData" :stripe="true" style="width: 100%" @selection-change="selectionChange">
      <el-table-column type="selection" align="center" />
      <el-table-column prop="type" align="center" label="类型" />
      <el-table-column prop="subjectName" align="center" label="题目" />
      <el-table-column prop="score" align="center" label="分值" />
      <el-table-column prop="createTime" align="center" label="添加时间" />
      <el-table-column prop="publishName" align="center" label="发布者" />
      <el-table-column align="center" label="操作" width="200">
        <template slot-scope="scope">
          <el-button type="text" class="table-delete-btn"
            @click="handleDelete(scope.$index, scope.row)"></el-button><!--删除-->
        </template>
      </el-table-column>
    </el-table>
    <XPagination ref="pageInfo" :total="total" :get-data="getList" />
  </div>
</template>

<script>
import XPagination from "../../components/xpagination/XPagination";
import * as TopicManger from "../../api/TopicManger"
export default {
  components: { XPagination },
  props: {
    // sysActivityUid: {
    //   type: String
    // }
  },
  data () {
    return {
      searchForm: {

      },
      tableData: [],
      total: 0,
      loading: false,
      sysActivityUid: '',
      typeList: [
        '判断题',
        '单选题',
        '多选题',
        '填空题',],
      selectionData: []
    };
  },

  mounted () {
    this.handleSearch()
  },

  methods: {
    getList (pageInfo) {
      const param = {
        ...this.searchForm,
        ...pageInfo,
        // sysActivityUid: this.sysActivityUid
      }
      TopicManger.queryByPage(param).then(response => {
        console.log(response)
        this.tableData = response.data.data.rows
        this.total = response.data.data.total
        //this.loading = false
      }).catch(error => {
        console.log(error)
      })
    },
    handleSearch () {
      this.$refs.pageInfo.loadData()
    },
    selectionChange (data) {
      this.selectionData = data
    },
    add () {
      this.$emit('getName',this.selectionData)
    }
  },
};
</script>

<style lang="scss" scoped></style>